﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using CodeGame.ServerObjects;

namespace CodeGame.Networking.Serverside.ClientServerPackets
{
    class EntityTexturePacket : ServerPacket
    {
        public override ClientServerNet GetID()
        {
            return ClientServerNet.EntityTextureRequest;
        }

        public override void Handle(Lidgren.Network.NetIncomingMessage message, Lidgren.Network.NetConnection sender)
        {
            string id = message.ReadString();
            string texture = message.ReadString();

            Player ply = ServerSingletons.Players.GetPlayer(sender);
            if (ply.WithdrawResouces(Balence.TextureEntity))
            {
                ServerSingletons.World.GetEntity(true, id).TextureEnt(id, texture);
            }
        }  
    }
}
